package com.jack.hhitseat.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jack.hhitseat.bean.Hhit;
import com.jack.hhitseat.bean.InfoSearch;
import com.jack.hhitseat.bean.Seat;
import com.jack.hhitseat.mapper.main.HhitMapper;
import com.jack.hhitseat.model.LayuiMap;

@Service
public class HhitService {
	@Autowired
	private HhitMapper hhitMapper;

	public void save(Hhit info) {
		hhitMapper.insert(info);
	}

	public int count(int num) {
		return hhitMapper.count(num);
	}

	public Object list(InfoSearch infoSearch) {
		infoSearch.setPage((infoSearch.getPage()-1) * infoSearch.getLimit());
		
		LayuiMap<Hhit> result = new LayuiMap<>();
		List<Hhit> seats = new ArrayList<Hhit>();
		
		try {
			seats = hhitMapper.list(infoSearch);
			result.setCount(hhitMapper.countList(infoSearch));
		}catch (Exception e) {
			e.printStackTrace();
			result.setCode("0");
			result.setData(null);
			return result;
		}
		result.setCode("0");
		result.setData(seats);
		return result;
	}
	
}
